<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <!--  -->
  <form id="myform" action="http://www.baidu.com">
    用户名：<input type="text" name="username">
    <br>
    密码: <input type="password" name="pass" />
    <br>
    年龄:<input type="text" id="age">
    <div id="show"></div>
    <br>
    <input type="reset">
    <input type="submit" />
  </form>
  <script>
    var myform = document.getElementById("myform");
    myform.onsubmit = function () { //1.onsubmit 表单提交事件
      alert("表单正在提交,稍等...")
      return false  //阻止默认事件
    }
    myform.onreset = function () {//2.onreset 表单重置事件
      alert("表单已经重置")
    }
    var age = document.getElementById("age");
    var show = document.getElementById("show")
    age.oninput = function () {//3.oninput 实时输入事件
      console.log(this.value)
      show.innerHTML = this.value;
    }
  </script>
</body>

</html>